package com.zfjt.web;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zfjt.entity.ClientmessageBean;
import com.zfjt.service.ClientmessageBeanService;
import com.zfjt.service.UserService;
import com.zfjt.utils.DateUtil;
import com.zfjt.utils.StringUtil;

/**
 * 
 * @author tang
 * @date 2017年4月17日 上午9:48:11
 * 处理订单控制器
 */
@Controller
public class ClientMessageWebController{

	@Autowired
	private ClientmessageBeanService mClientMessageService;
	
	@Autowired
	private UserService mUsre;
	
	private String mName =null;
	
	//	订单实体类
	private ClientmessageBean messageBean =null;
	
	//	产品属性  产品类型A1,A2,A3,B1,B2,B3
	private String product = null;
	
	//	图片属性
	private String img04Type = null;

	// 跳转到未完成订单页面
	@RequestMapping("noFinishOrder")
	public String noFinishOrder(){
		return "order/noFinishOrder";
	}
	
	// 跳转到待审核订单页面
	@RequestMapping("noCheck")
	public String successOrderPage(){
		return "order/noCheck";
	}
	// 跳转到已通过订单页面
	@RequestMapping("passedOrder")
	public String failureOrderPage(){
		return "order/passedOrder";
	}
	// 跳转到已驳回订单页面
	@RequestMapping("refusedOrder")
	public String refusedOrder(){
		return "order/refusedOrder";
	}
	
	// 跳转到已拒绝订单页面
	@RequestMapping("rejectOrder")
	public String rejectOrder(){
		return "order/rejectOrder";
	}
	
	
	// 神州跳转到未完成订单页面
	@RequestMapping("noFinishOrder2")
	public String noFinishOrder2(){
		return "order/noFinishOrder2";
	}
	
	// 神州跳转到待审核订单页面
	@RequestMapping("noCheck2")
	public String successOrderPage2(){
		return "order/noCheck2";
	}
	// 神州跳转到已通过订单页面
	@RequestMapping("passedOrder2")
	public String failureOrderPage2(){
		return "order/passedOrder2";
	}
	// 神州跳转到已驳回订单页面
	@RequestMapping("refusedOrder2")
	public String refusedOrder2(){
		return "order/refusedOrder2";
	}
	
	// 神州跳转到已拒绝订单页面
	@RequestMapping("rejectOrder2")
	public String rejectOrder2(){
		return "order/rejectOrder2";
	}	
			
	
	//添加放款金额
	@RequestMapping("updateOrder/{id}")
	@ResponseBody
	public  Integer saveMoney(@PathVariable String id,ClientmessageBean mClientMessage){
		Integer updateByPrimaryKey = mClientMessageService.updateByPrimaryKeySelective(mClientMessage);
		return updateByPrimaryKey;
	}
	
	// 照片通过与拒绝的审核
	@RequestMapping("subImg")
	public String subImg(HttpServletRequest request){
		Short id =  Short.parseShort(request.getParameter("id"));
		String name = request.getParameter("str");
		ClientmessageBean clientMessageBean = mClientMessageService.selectByPrimaryKey(id);
		mClientMessageService.selectByPrimaryKey(id);
		String[] pValues = request.getParameterValues("img");
		StringBuilder sb = new StringBuilder();
		if (name.equals("通过")) {
			clientMessageBean.setType("3");
			mClientMessageService.updateByPrimaryKeySelective(clientMessageBean);
		}else if (name.equals("驳回")) {
			clientMessageBean.setRejectImg("");
			int is04 = 0;
			int is06 = 0;
			List<String> data = new ArrayList<>();
			clientMessageBean.setType("4");
			for(int i=0;i<pValues.length;i++){
				String rejectImg = pValues[i].substring(pValues[i].indexOf("Img"), pValues[i].indexOf(".jpg"));
				String str =rejectImg.substring(0, 5);
				if (str.equals("Img04")) {
					if (is04 == 0) {
						clientMessageBean.setRejectImg(clientMessageBean.getRejectImg()  + "," + "Img04_" + clientMessageBean.getImg04Type());
						is04 = 1;
					}
				}else if (str.equals("Img06")) {
					if (is06 == 0) {
						clientMessageBean.setRejectImg(clientMessageBean.getRejectImg() + "," + "Img06");
						is06 = 1;
					}
				}else {
					clientMessageBean.setRejectImg(clientMessageBean.getRejectImg() + "," + rejectImg );
				}
			}	
			mClientMessageService.updateByPrimaryKeySelective(clientMessageBean);
		}else if (name.equals("拒绝")) {
			clientMessageBean.setType("5");
			mClientMessageService.updateByPrimaryKeySelective(clientMessageBean);
		}
		return "order/passedOrder";
	}
 

	// 未完成订单列表数据
	@RequestMapping(value = "noFinishOrderDate", method = RequestMethod.POST)
	@ResponseBody
	public List<ClientmessageBean> noFinishOrderDate(){
		List<ClientmessageBean> orders = new ArrayList<ClientmessageBean>();
		List<ClientmessageBean> order = mClientMessageService.selectAll();
		Iterator<ClientmessageBean> iterator = order.iterator();
		for (int i = 0; i < order.size(); i++){
			if (iterator.hasNext()){
				ClientmessageBean messageBean = iterator.next();
				if (messageBean.getType().equals("1")){
					orders.add(messageBean);
				} 
			}
		}
		return orders;
	}
	
	// 待审核订单列表数据
	@RequestMapping(value = "noCheckData", method = RequestMethod.POST)
	@ResponseBody
	public List<ClientmessageBean> noCheckData(){
		List<ClientmessageBean> orders = new ArrayList<ClientmessageBean>();
		List<ClientmessageBean> data = mClientMessageService.selectAll();
		Iterator<ClientmessageBean> iterator = data.iterator();
		for (int i = 0; i < data.size(); i++){
			if (iterator.hasNext()){
				ClientmessageBean messageBean = iterator.next();
				if (messageBean.getType().equals("2")){
					messageBean.setAddtime(DateUtil.timeStamp2Date(messageBean.getAddtime()));
					messageBean.setType("待审核");
					switch (messageBean.getProduct()) {
					case "A1":
						messageBean.setProduct("周坊高能贷60%");
						break;
					case "A2":
						messageBean.setProduct("周坊高能贷70%");
						break;
					case "A3":
						messageBean.setProduct("周坊高能贷80%");
						break;
					case "B1":
						messageBean.setProduct("低息贷60%");
						break;
					case "B2":
						messageBean.setProduct("低息贷70%");
						break;
					case "B3":
						messageBean.setProduct("低息贷80%");
						break;
					case "C1":
						messageBean.setProduct("浦发高能贷60%");
						break;
					case "C2":
						messageBean.setProduct("浦发高能贷70%");
						break;
					case "C3":
						messageBean.setProduct("浦发高能贷80%");
						break;
					default:
						break;
					}
					messageBean.setGenre(messageBean.getGenre() + "个月");
					messageBean.setAffiliationWangdian(messageBean.getText1());
					orders.add(messageBean);
				} 
			}
		}
		return orders;
	}
	
	// 已通过订单列表数据
	@RequestMapping(value = "passedOrderData", method = RequestMethod.POST)
	@ResponseBody
	public List<ClientmessageBean> passedOrder(){
		List<ClientmessageBean> orders = new ArrayList<ClientmessageBean>();
		List<ClientmessageBean> order = mClientMessageService.selectAll();
		Iterator<ClientmessageBean> iterator = order.iterator();
		for (int i = 0; i < order.size(); i++){
			if (iterator.hasNext()){
				ClientmessageBean messageBean = iterator.next();
				if (messageBean.getType().equals("3")){
					messageBean.setType("已通过");
					switch (messageBean.getProduct()) {
					case "A1":
						messageBean.setProduct("周坊高能贷60%");
						break;
					case "A2":
						messageBean.setProduct("周坊高能贷70%");
						break;
					case "A3":
						messageBean.setProduct("周坊高能贷80%");
						break;
					case "B1":
						messageBean.setProduct("低息贷60%");
						break;
					case "B2":
						messageBean.setProduct("低息贷70%");
						break;
					case "B3":
						messageBean.setProduct("低息贷80%");
						break;
					case "C1":
						messageBean.setProduct("浦发高能贷60%");
						break;
					case "C2":
						messageBean.setProduct("浦发高能贷70%");
						break;
					case "C3":
						messageBean.setProduct("浦发高能贷80%");
						break;
					default:
						break;
					}
					messageBean.setAddtime(DateUtil.timeStamp2Date(messageBean.getAddtime()));
					messageBean.setAffiliationWangdian(messageBean.getText1());
					orders.add(messageBean);
				} 
			}
		}
		return orders;
	}
	
	// 已驳回订单列表数据
	@RequestMapping(value = "refusedOrderData", method = RequestMethod.POST)
	@ResponseBody
	public List<ClientmessageBean> refusedOrderData(){
		List<ClientmessageBean> orders = new ArrayList<ClientmessageBean>();
		List<ClientmessageBean> order = mClientMessageService.selectAll();
		Iterator<ClientmessageBean> iterator = order.iterator();
		for (int i = 0; i < order.size(); i++){
			if (iterator.hasNext()){
				ClientmessageBean messageBean = iterator.next();
				if (messageBean.getType().equals("4")){
					messageBean.setType("已驳回");
					switch (messageBean.getProduct()) {
					case "A1":
						messageBean.setProduct("周坊高能贷60%");
						break;
					case "A2":
						messageBean.setProduct("周坊高能贷70%");
						break;
					case "A3":
						messageBean.setProduct("周坊高能贷80%");
						break;
					case "B1":
						messageBean.setProduct("低息贷60%");
						break;
					case "B2":
						messageBean.setProduct("低息贷70%");
						break;
					case "B3":
						messageBean.setProduct("低息贷80%");
						break;
					case "C1":
						messageBean.setProduct("浦发高能贷60%");
						break;
					case "C2":
						messageBean.setProduct("浦发高能贷70%");
						break;
					case "C3":
						messageBean.setProduct("浦发高能贷80%");
						break;
					default:
						break;
				
					}
					messageBean.setAddtime(DateUtil.timeStamp2Date(messageBean.getAddtime()));
					messageBean.setAffiliationWangdian(messageBean.getText1());
					orders.add(messageBean);
				} 
			}
		}
		return orders;
	}
	
	// 已拒绝订单列表数据
	@RequestMapping(value = "rejectOrderData", method = RequestMethod.POST)
	@ResponseBody
	public List<ClientmessageBean> rejectOrderData(){
			List<ClientmessageBean> orders = new ArrayList<ClientmessageBean>();
			List<ClientmessageBean> order = mClientMessageService.selectAll();
			Iterator<ClientmessageBean> iterator = order.iterator();
			for (int i = 0; i < order.size(); i++){
				if (iterator.hasNext()){
					ClientmessageBean messageBean = iterator.next();
					if (messageBean.getType().equals("5")){
						messageBean.setType("已拒绝");
						switch (messageBean.getProduct()) {
						case "A1":
							messageBean.setProduct("周坊高能贷60%");
							break;
						case "A2":
							messageBean.setProduct("周坊高能贷70%");
							break;
						case "A3":
							messageBean.setProduct("周坊高能贷80%");
							break;
						case "B1":
							messageBean.setProduct("低息贷60%");
							break;
						case "B2":
							messageBean.setProduct("低息贷70%");
							break;
						case "B3":
							messageBean.setProduct("低息贷80%");
							break;
						case "C1":
							messageBean.setProduct("浦发高能贷60%");
							break;
						case "C2":
							messageBean.setProduct("浦发高能贷70%");
							break;
						case "C3":
							messageBean.setProduct("浦发高能贷80%");
							break;
						default:
							break;
						}
						messageBean.setAddtime(DateUtil.timeStamp2Date(messageBean.getAddtime()));
						messageBean.setAffiliationWangdian(messageBean.getText1());
						orders.add(messageBean);
					} 
				}
			}
			return orders;
		}
	
	/**
	 * 神州系统返回的数据
	 */
	// 神州系统未完成订单列表数据
		@RequestMapping(value = "noFinishOrderDate2", method = RequestMethod.POST)
		@ResponseBody
		public List<ClientmessageBean> noFinishOrderDate2(){
			List<ClientmessageBean> orders = new ArrayList<ClientmessageBean>();
			List<ClientmessageBean> order = mClientMessageService.selectAll();
			Iterator<ClientmessageBean> iterator = order.iterator();
			for (int i = 0; i < order.size(); i++){
				if (iterator.hasNext()){
					ClientmessageBean messageBean = iterator.next();
					if (messageBean.getType().equals("1")){
						if (messageBean.getAffiliationWangdian().equals("神州闪贷")) {	
							String [] str = StringUtil.convertStrToArray(messageBean.getName());
							messageBean.setName(str[0]);
							orders.add(messageBean);
						}
					} 
				}
			}
			return orders;
		}
		
		// 神州系统待审核订单列表数据
		@RequestMapping(value = "noCheckData2", method = RequestMethod.POST)
		@ResponseBody
		public List<ClientmessageBean> noCheckData2(){
			
			List<ClientmessageBean> orders = new ArrayList<ClientmessageBean>();
			
			List<ClientmessageBean> data = mClientMessageService.selectAll();
			
			Iterator<ClientmessageBean> iterator = data.iterator();
			
			for (int i = 0; i < data.size(); i++){
				if (iterator.hasNext()){
					ClientmessageBean messageBean = iterator.next();
					if (messageBean.getType().equals("2")){
						messageBean.setAddtime(DateUtil.timeStamp2Date(messageBean.getAddtime()));
						messageBean.setType("待审核");
						switch (messageBean.getProduct()) {
						case "A1":
							messageBean.setProduct("周坊高能贷60%");
							break;
						case "A2":
							messageBean.setProduct("周坊高能贷70%");
							break;
						case "A3":
							messageBean.setProduct("周坊高能贷80%");
							break;
						case "B1":
							messageBean.setProduct("低息贷60%");
							break;
						case "B2":
							messageBean.setProduct("低息贷70%");
							break;
						case "B3":
							messageBean.setProduct("低息贷80%");
							break;
						case "C1":
							messageBean.setProduct("浦发高能贷60%");
							break;
						case "C2":
							messageBean.setProduct("浦发高能贷70%");
							break;
						case "C3":
							messageBean.setProduct("浦发高能贷80%");
							break;
						default:
							break;
						}
						messageBean.setGenre(messageBean.getGenre() + "个月");
						messageBean.setAffiliationWangdian(messageBean.getText1());
						if (messageBean.getAffiliationWangdian().equals("神州闪贷")) {
							orders.add(messageBean);
						}
					} 
				}
			}
			return orders;
		}
		
		// 神州系统已通过订单列表数据
		@RequestMapping(value = "passedOrderData2", method = RequestMethod.POST)
		@ResponseBody
		public List<ClientmessageBean> passedOrder2(){
			
			List<ClientmessageBean> orders = new ArrayList<ClientmessageBean>();
			
			List<ClientmessageBean> order = mClientMessageService.selectAll();
			
			Iterator<ClientmessageBean> iterator = order.iterator();
			
			for (int i = 0; i < order.size(); i++){
				if (iterator.hasNext()){
					ClientmessageBean messageBean = iterator.next();
					if (messageBean.getType().equals("3")){
						messageBean.setType("已通过");
						switch (messageBean.getProduct()) {
						case "A1":
							messageBean.setProduct("周坊高能贷60%");
							break;
						case "A2":
							messageBean.setProduct("周坊高能贷70%");
							break;
						case "A3":
							messageBean.setProduct("周坊高能贷80%");
							break;
						case "B1":
							messageBean.setProduct("低息贷60%");
							break;
						case "B2":
							messageBean.setProduct("低息贷70%");
							break;
						case "B3":
							messageBean.setProduct("低息贷80%");
							break;
						case "C1":
							messageBean.setProduct("浦发高能贷60%");
							break;
						case "C2":
							messageBean.setProduct("浦发高能贷70%");
							break;
						case "C3":
							messageBean.setProduct("浦发高能贷80%");
							break;
						default:
							break;
						}
						messageBean.setAddtime(DateUtil.timeStamp2Date(messageBean.getAddtime()));
						messageBean.setAffiliationWangdian(messageBean.getText1());
						if (messageBean.getAffiliationWangdian().equals("神州闪贷")) {
							orders.add(messageBean);
						}
					} 
				}
			}
			return orders;
		}
		
		// 神州系统已驳回订单列表数据
		@RequestMapping(value = "refusedOrderData2", method = RequestMethod.POST)
		@ResponseBody
		public List<ClientmessageBean> refusedOrderData2(){
			
			List<ClientmessageBean> orders = new ArrayList<ClientmessageBean>();
			
			List<ClientmessageBean> order = mClientMessageService.selectAll();
			
			Iterator<ClientmessageBean> iterator = order.iterator();
			
			for (int i = 0; i < order.size(); i++){
				if (iterator.hasNext()){
					ClientmessageBean messageBean = iterator.next();
					if (messageBean.getType().equals("4")){
						messageBean.setType("已驳回");
						switch (messageBean.getProduct()) {
						case "A1":
							messageBean.setProduct("周坊高能贷60%");
							break;
						case "A2":
							messageBean.setProduct("周坊高能贷70%");
							break;
						case "A3":
							messageBean.setProduct("周坊高能贷80%");
							break;
						case "B1":
							messageBean.setProduct("低息贷60%");
							break;
						case "B2":
							messageBean.setProduct("低息贷70%");
							break;
						case "B3":
							messageBean.setProduct("低息贷80%");
							break;
						case "C1":
							messageBean.setProduct("浦发高能贷60%");
							break;
						case "C2":
							messageBean.setProduct("浦发高能贷70%");
							break;
						case "C3":
							messageBean.setProduct("浦发高能贷80%");
							break;
						default:
							break;
						}
						messageBean.setAddtime(DateUtil.timeStamp2Date(messageBean.getAddtime()));
						messageBean.setAffiliationWangdian(messageBean.getText1());
						if (messageBean.getAffiliationWangdian().equals("神州闪贷")) {
							orders.add(messageBean);
						}
					} 
				}
			}
			return orders;
		}
		
		// 神州系统已拒绝订单列表数据
		@RequestMapping(value = "rejectOrderData2", method = RequestMethod.POST)
		@ResponseBody
		public List<ClientmessageBean> rejectOrderData2(){
				
				List<ClientmessageBean> orders = new ArrayList<ClientmessageBean>();
				
				List<ClientmessageBean> order = mClientMessageService.selectAll();
				
				Iterator<ClientmessageBean> iterator = order.iterator();
				
				for (int i = 0; i < order.size(); i++){
					if (iterator.hasNext()){
						ClientmessageBean messageBean = iterator.next();
						if (messageBean.getType().equals("5")){
							messageBean.setType("已拒绝");
							switch (messageBean.getProduct()) {
							case "A1":
								messageBean.setProduct("周坊高能贷60%");
								break;
							case "A2":
								messageBean.setProduct("周坊高能贷70%");
								break;
							case "A3":
								messageBean.setProduct("周坊高能贷80%");
								break;
							case "B1":
								messageBean.setProduct("低息贷60%");
								break;
							case "B2":
								messageBean.setProduct("低息贷70%");
								break;
							case "B3":
								messageBean.setProduct("低息贷80%");
								break;
							case "C1":
								messageBean.setProduct("浦发高能贷60%");
								break;
							case "C2":
								messageBean.setProduct("浦发高能贷70%");
								break;
							case "C3":
								messageBean.setProduct("浦发高能贷80%");
								break;
							default:
								break;
							}
							messageBean.setAddtime(DateUtil.timeStamp2Date(messageBean.getAddtime()));
							messageBean.setAffiliationWangdian(messageBean.getText1());
							if (messageBean.getAffiliationWangdian().equals("神州闪贷")) {
								orders.add(messageBean);
							}
						} 
					}
				}
				return orders;
			}
		
		
//	获取基础信息图片获取地址,并截取其中一段,然后重新设置到对象的属性中
//	这些信息是所有产品都需要展示的
	private void setImg0123(){
		String img0101 = messageBean.getImg0101();
    	String img0102 = messageBean.getImg0102();
    	String img0103 = messageBean.getImg0103();
    	String img0104 = messageBean.getImg0104();
    	String img0105 = messageBean.getImg0105();
    	String img0106 = messageBean.getImg0106();
    	String img0107 = messageBean.getImg0107();
    	String img0108 = messageBean.getImg0108();
    	String img0109 = messageBean.getImg0109();
    	String img0110 = messageBean.getImg0110();
    	String img0111 = messageBean.getImg0111();
    	
    	String img0201 = messageBean.getImg0201();
    	String img0202 = messageBean.getImg0202();
    	String img0203 = messageBean.getImg0203();
    	String img0204 = messageBean.getImg0204();
    	String img0205 = messageBean.getImg0205();
    	String img0206 = messageBean.getImg0206();
    	String img0207 = messageBean.getImg0207();
    	String img0208 = messageBean.getImg0208();
    	String img0209 = messageBean.getImg0209();
    	String img0210 = messageBean.getImg0210();
    	String img0211 = messageBean.getImg0211();
    	
    	String img0301 = messageBean.getImg0301();
    	String img0302 = messageBean.getImg0302();
    	String img0303 = messageBean.getImg0303();
    	String img0304 = messageBean.getImg0304();
    	String img0305 = messageBean.getImg0305();
    	String img0306 = messageBean.getImg0306();
    	String img0307 = messageBean.getImg0307();
    	String img0308 = messageBean.getImg0308();
    	String img0309 = messageBean.getImg0309();
    	String img0310 = messageBean.getImg0310();
    	String img0311 = messageBean.getImg0311();
    	String img0312 = messageBean.getImg0312();
    	String img0313 = messageBean.getImg0313();
    	
//    	截取数据库图片路径的一段
    	img0101 = img0101.substring(img0101.indexOf("\\zfjt"), img0101.length());
    	img0102 = img0102.substring(img0102.indexOf("\\zfjt"), img0102.length());
    	img0103 = img0103.substring(img0103.indexOf("\\zfjt"), img0103.length());
    	img0104 = img0104.substring(img0104.indexOf("\\zfjt"), img0104.length());
    	img0105 = img0105.substring(img0105.indexOf("\\zfjt"), img0105.length());
    	img0106 = img0106.substring(img0106.indexOf("\\zfjt"), img0106.length());
    	img0107 = img0107.substring(img0107.indexOf("\\zfjt"), img0107.length());
    	img0108 = img0108.substring(img0108.indexOf("\\zfjt"), img0108.length());
    	img0109 = img0109.substring(img0109.indexOf("\\zfjt"), img0109.length());
    	img0110 = img0110.substring(img0110.indexOf("\\zfjt"), img0110.length());
    	img0111 = img0111.substring(img0111.indexOf("\\zfjt"), img0111.length());
    	
    	img0201 = img0201.substring(img0201.indexOf("\\zfjt"), img0201.length());
    	img0202 = img0202.substring(img0202.indexOf("\\zfjt"), img0202.length());
    	img0203 = img0203.substring(img0203.indexOf("\\zfjt"), img0203.length());
    	img0204 = img0204.substring(img0204.indexOf("\\zfjt"), img0204.length());
    	img0205 = img0205.substring(img0205.indexOf("\\zfjt"), img0205.length());
    	img0206 = img0206.substring(img0206.indexOf("\\zfjt"), img0206.length());
    	img0207 = img0207.substring(img0207.indexOf("\\zfjt"), img0207.length());
    	img0208 = img0208.substring(img0208.indexOf("\\zfjt"), img0208.length());
    	img0209 = img0209.substring(img0209.indexOf("\\zfjt"), img0209.length());
    	img0210 = img0210.substring(img0210.indexOf("\\zfjt"), img0210.length());
    	img0211 = img0211.substring(img0211.indexOf("\\zfjt"), img0211.length());
    	
    	img0301 = img0301.substring(img0301.indexOf("\\zfjt"), img0301.length());
    	img0302 = img0302.substring(img0302.indexOf("\\zfjt"), img0302.length());
    	img0303 = img0303.substring(img0303.indexOf("\\zfjt"), img0303.length());
    	img0304 = img0304.substring(img0304.indexOf("\\zfjt"), img0304.length());
    	img0305 = img0305.substring(img0305.indexOf("\\zfjt"), img0305.length());
    	img0306 = img0306.substring(img0306.indexOf("\\zfjt"), img0306.length());
    	img0307 = img0307.substring(img0307.indexOf("\\zfjt"), img0307.length());
    	img0308 = img0308.substring(img0308.indexOf("\\zfjt"), img0308.length());
    	img0309 = img0309.substring(img0309.indexOf("\\zfjt"), img0309.length());
    	img0310 = img0310.substring(img0310.indexOf("\\zfjt"), img0310.length());
    	img0311 = img0311.substring(img0311.indexOf("\\zfjt"), img0311.length());
    	img0312 = img0312.substring(img0312.indexOf("\\zfjt"), img0312.length());
    	img0313 = img0313.substring(img0313.indexOf("\\zfjt"), img0313.length());
    	
//    	设置图片地址,以供前台直接获取变成图片连接
    	messageBean.setImg0101(img0101);
    	messageBean.setImg0102(img0102);
    	messageBean.setImg0103(img0103);
    	messageBean.setImg0104(img0104);
    	messageBean.setImg0105(img0105);
    	messageBean.setImg0106(img0106);
    	messageBean.setImg0107(img0107);
    	messageBean.setImg0108(img0108);
    	messageBean.setImg0109(img0109);
    	messageBean.setImg0110(img0110);
    	messageBean.setImg0111(img0111);
    	
    	messageBean.setImg0201(img0201);
    	messageBean.setImg0202(img0202);
    	messageBean.setImg0203(img0203);
    	messageBean.setImg0204(img0204);
    	messageBean.setImg0205(img0205);
    	messageBean.setImg0206(img0206);
    	messageBean.setImg0207(img0207);
    	messageBean.setImg0208(img0208);
    	messageBean.setImg0209(img0209);
    	messageBean.setImg0210(img0210);
    	messageBean.setImg0211(img0211);
    	
    	messageBean.setImg0301(img0301);
    	messageBean.setImg0302(img0302);
    	messageBean.setImg0303(img0303);
    	messageBean.setImg0304(img0304);
    	messageBean.setImg0305(img0305);
    	messageBean.setImg0306(img0306);
    	messageBean.setImg0307(img0307);
    	messageBean.setImg0308(img0308);
    	messageBean.setImg0309(img0309);
    	messageBean.setImg0310(img0310);
    	messageBean.setImg0311(img0311);
    	messageBean.setImg0312(img0312);
    	messageBean.setImg0313(img0313);
	}
	
//	img04Type,用户判断财产证明,如果等于1展示银行流水图片,如果等于2展示房产证明图片
	private void setImg04(){
		if (img04Type.equals("1")){
			if (StringUtil.isNotEmpty(messageBean.getImg0401())) {
				String img0401 = messageBean.getImg0401().substring(messageBean.getImg0401().indexOf("\\zfjt"), messageBean.getImg0401().length());
				messageBean.setImg0401(img0401);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0402())) {
				String img0402 = messageBean.getImg0402().substring(messageBean.getImg0402().indexOf("\\zfjt"), messageBean.getImg0402().length());
				messageBean.setImg0402(img0402);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0403())) {
				String img0403 = messageBean.getImg0403().substring(messageBean.getImg0403().indexOf("\\zfjt"), messageBean.getImg0403().length());
				messageBean.setImg0403(img0403);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0404())) {
				String img0404 = messageBean.getImg0404().substring(messageBean.getImg0404().indexOf("\\zfjt"), messageBean.getImg0404().length());
				messageBean.setImg0404(img0404);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0405())) {
				String img0405 = messageBean.getImg0405().substring(messageBean.getImg0405().indexOf("\\zfjt"), messageBean.getImg0405().length());
				messageBean.setImg0405(img0405);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0406())) {
				String img0406 = messageBean.getImg0406().substring(messageBean.getImg0406().indexOf("\\zfjt"), messageBean.getImg0406().length());
				messageBean.setImg0406(img0406);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0407())) {
				String img0407 = messageBean.getImg0407().substring(messageBean.getImg0407().indexOf("\\zfjt"), messageBean.getImg0407().length());
				messageBean.setImg0407(img0407);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0408())) {
				String img0408 = messageBean.getImg0408().substring(messageBean.getImg0408().indexOf("\\zfjt"), messageBean.getImg0408().length());
				messageBean.setImg0408(img0408);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0409())) {
				String img0409 = messageBean.getImg0409().substring(messageBean.getImg0409().indexOf("\\zfjt"), messageBean.getImg0409().length());
				messageBean.setImg0409(img0409);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0410())) {
				String img0410 = messageBean.getImg0410().substring(messageBean.getImg0410().indexOf("\\zfjt"), messageBean.getImg0410().length());
				messageBean.setImg0410(img0410);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0411())) {
				String img0411 = messageBean.getImg0411().substring(messageBean.getImg0411().indexOf("\\zfjt"), messageBean.getImg0411().length());
				messageBean.setImg0411(img0411);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0412())) {
				String img0412 = messageBean.getImg0412().substring(messageBean.getImg0412().indexOf("\\zfjt"), messageBean.getImg0412().length());
				messageBean.setImg0412(img0412);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0413())) {
				String img0413 = messageBean.getImg0413().substring(messageBean.getImg0413().indexOf("\\zfjt"), messageBean.getImg0413().length());
				messageBean.setImg0413(img0413);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0414())) {
				String img0414 = messageBean.getImg0414().substring(messageBean.getImg0414().indexOf("\\zfjt"), messageBean.getImg0414().length());
				messageBean.setImg0414(img0414);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0415())) {
				String img0415 = messageBean.getImg0415().substring(messageBean.getImg0415().indexOf("\\zfjt"), messageBean.getImg0415().length());
				messageBean.setImg0415(img0415);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0416())) {
				String img0416 = messageBean.getImg0416().substring(messageBean.getImg0416().indexOf("\\zfjt"), messageBean.getImg0416().length());
				messageBean.setImg0416(img0416);
			}	
	    	
		}else if(img04Type.equals("2")){
			if (StringUtil.isNotEmpty(messageBean.getImg0417())) {
				String img0417 = messageBean.getImg0417().substring(messageBean.getImg0417().indexOf("\\zfjt"), messageBean.getImg0417().length());
				messageBean.setImg0417(img0417);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0418())) {
				String img0418 = messageBean.getImg0418().substring(messageBean.getImg0418().indexOf("\\zfjt"), messageBean.getImg0418().length());
				messageBean.setImg0418(img0418);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0419())) {
				String img0419 = messageBean.getImg0419().substring(messageBean.getImg0419().indexOf("\\zfjt"), messageBean.getImg0419().length());
				messageBean.setImg0419(img0419);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0420())) {
				String img0420 = messageBean.getImg0420().substring(messageBean.getImg0420().indexOf("\\zfjt"), messageBean.getImg0420().length());
				messageBean.setImg0420(img0420);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0421())) {
				String img0421 = messageBean.getImg0421().substring(messageBean.getImg0421().indexOf("\\zfjt"), messageBean.getImg0421().length());
				messageBean.setImg0421(img0421);
			}
			if (StringUtil.isNotEmpty(messageBean.getImg0422())) {
				String img0422 = messageBean.getImg0422().substring(messageBean.getImg0422().indexOf("\\zfjt"), messageBean.getImg0422().length());
				messageBean.setImg0421(img0422);
			}			
		}    	
	}
	
	private void setImg0506(){
    	String img0501 = messageBean.getImg0501();
    	String img0502 = messageBean.getImg0502();
    	
    	img0501 = img0501.substring(img0501.indexOf("\\zfjt"), img0501.length());
    	img0502 = img0502.substring(img0502.indexOf("\\zfjt"), img0502.length());
    	
    	messageBean.setImg0501(img0501);
    	messageBean.setImg0502(img0502);
    	
    	if (StringUtil.isNotEmpty(messageBean.getImg0601())) {
			String img0601 = messageBean.getImg0601().substring(messageBean.getImg0601().indexOf("\\zfjt"), messageBean.getImg0601().length());
			messageBean.setImg0601(img0601);
		}
    	if (StringUtil.isNotEmpty(messageBean.getImg0602())) {
			String img0602 = messageBean.getImg0602().substring(messageBean.getImg0602().indexOf("\\zfjt"), messageBean.getImg0602().length());
			messageBean.setImg0602(img0602);
		}
    	if (StringUtil.isNotEmpty(messageBean.getImg0603())) {
			String img0603 = messageBean.getImg0603().substring(messageBean.getImg0603().indexOf("\\zfjt"), messageBean.getImg0603().length());
			messageBean.setImg0603(img0603);
		}
    	if (StringUtil.isNotEmpty(messageBean.getImg0604())) {
			String img0604 = messageBean.getImg0604().substring(messageBean.getImg0604().indexOf("\\zfjt"), messageBean.getImg0604().length());
			messageBean.setImg0604(img0604);
		}
    	if (StringUtil.isNotEmpty(messageBean.getImg0605())) {
			String img0605 = messageBean.getImg0605().substring(messageBean.getImg0605().indexOf("\\zfjt"), messageBean.getImg0605().length());
			messageBean.setImg0605(img0605);
		}
    	if (StringUtil.isNotEmpty(messageBean.getImg0606())) {
			String img0606 = messageBean.getImg0606().substring(messageBean.getImg0606().indexOf("\\zfjt"), messageBean.getImg0606().length());
			messageBean.setImg0606(img0606);
		}
    	if (StringUtil.isNotEmpty(messageBean.getImg0607())) {
			String img0607 = messageBean.getImg0607().substring(messageBean.getImg0607().indexOf("\\zfjt"), messageBean.getImg0607().length());
			messageBean.setImg0607(img0607);
		}
    	if (StringUtil.isNotEmpty(messageBean.getImg0608())) {
			String img0608 = messageBean.getImg0608().substring(messageBean.getImg0608().indexOf("\\zfjt"), messageBean.getImg0608().length());
			messageBean.setImg0608(img0608);
		}
    	if (StringUtil.isNotEmpty(messageBean.getImg0609())) {
			String img0609 = messageBean.getImg0609().substring(messageBean.getImg0609().indexOf("\\zfjt"), messageBean.getImg0609().length());
			messageBean.setImg0609(img0609);
		}

	}
	
	private void setImg07(){
		String img0701 = messageBean.getImg0701();
    	String img0702 = messageBean.getImg0702();
    	String img0703 = messageBean.getImg0703();
    	String img0704 = messageBean.getImg0704();
    	String img0705 = messageBean.getImg0705();
    	
    	img0701 = img0701.substring(img0701.indexOf("\\zfjt"), img0701.length());
    	img0702 = img0702.substring(img0702.indexOf("\\zfjt"), img0702.length());
    	img0703 = img0703.substring(img0703.indexOf("\\zfjt"), img0703.length());
    	img0704 = img0704.substring(img0704.indexOf("\\zfjt"), img0704.length());
    	img0705 = img0705.substring(img0705.indexOf("\\zfjt"), img0705.length());
    	
    	messageBean.setImg0701(img0701);
    	messageBean.setImg0702(img0702);
    	messageBean.setImg0703(img0703);
    	messageBean.setImg0704(img0704);
    	messageBean.setImg0705(img0705);
	}
	
//	图片审核
    @RequestMapping(value="checkImage/{name}")  
    public String showImageByType(@PathVariable String name , HttpServletRequest request,
    		HttpServletResponse response,Model model) throws Exception{  
    	this.mName = name;
    	short i = (short)Integer.parseInt(mName);
    	messageBean = mClientMessageService.selectByPrimaryKey(i);
//      产品类型A1,A2,A3,B1,B2,B3
        product = messageBean.getProduct();
//      imgType 1，表示银行流水，2，表示房产证明
        img04Type = messageBean.getImg04Type();
//		imgType = A1 第一个接口传本人基础资料照片信息（必传）
        switch (product){
		case "A1":
			setImg0123();
			model.addAttribute("orders", messageBean);
			System.out.println(messageBean+"A1");
			  return "order/A1";
		case "A2":
			setImg0123();
			setImg04();
			model.addAttribute("orders", messageBean);
			if (img04Type.equals("1")) {
				return "order/A2";
			}else {
				return "order/A3";
			}  
		case "A3":
			setImg0123();
			setImg04();
			setImg0506();
			model.addAttribute("orders", messageBean);
			if (img04Type.equals("1")) {
				return "order/A4";
			}else if (img04Type.equals("2")){
				return "order/A5";
			} 
		case "B1":
			setImg0123();
			setImg07();
			model.addAttribute("orders", messageBean);
			  return "order/B1";
		case "B2":
			setImg0123();
			setImg04();
			setImg07();
			model.addAttribute("orders", messageBean);
			if (img04Type.equals("1")) {
				return "order/B2";
			}else {
				return "order/B3";
			} 
		case "B3":
			setImg0123();
			setImg04();
			setImg0506();
			setImg07();
			model.addAttribute("orders", messageBean);
			if (img04Type.equals("1")) {
				return "order/B4";
			}else {
				return "order/B5";
			} 
		case "C1":
			setImg0123();
			setImg07();
			model.addAttribute("orders", messageBean);
			  return "order/B1";
		case "C2":
			setImg0123();
			setImg04();
			setImg07();
			model.addAttribute("orders", messageBean);
			if (img04Type.equals("1")) {
				return "order/B2";
			}else {
				return "order/B3";
			} 
		case "C3":
			setImg0123();
			setImg04();
			setImg0506();
			setImg07();
			model.addAttribute("orders", messageBean);
			if (img04Type.equals("1")) {
				return "order/B4";
			}else {
				return "order/B5";
			} 
		default:
			break;
		}
//        model.addAttribute("orders", messageBean);
//		System.out.println(messageBean+"基础信息展示");
//        return "order/showImag";
		return name;
	    
    }
}
